<template>
  <view class="form-overlay">
    <view class="form-container">
      <view class="form-header">
        <text>添加新项</text>
      </view>
      <view class="form-field">
        <text class="form-label">域名：</text>
        <input v-model="editItem.domain" class="form-input" />
      </view>
      <view class="form-field">
        <text class="form-label">对应ip：</text>
        <input v-model="editItem.ip" class="form-input" />
      </view>
      <view class="form-buttons">
        <button @click="saveAdd" class="form-button save-button">保存</button>
        <button @click="cancelAdd" class="form-button cancel-button">取消</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    editItem: {
      type: Object,
      required: true,
	  protocol:""
    }
  },
  data() {
    return {
      pickerKey: 0 // 用于强制重新渲染
    };
  },
  methods: {
    saveAdd() {
      this.$emit('saveAdd');
    },
    cancelAdd() {
      this.$emit('cancelAdd');
    }
  }
};
</script>

<style scoped>
.form-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.form-container {
  background-color: white;
  padding: 20rpx;
  border-radius: 10rpx;
  width: 80%;
  box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.1);
}

.form-header {
  font-size: 30rpx;
  font-weight: bold;
  margin-bottom: 20rpx;
  text-align: center;
}

.form-field {
  margin-bottom: 20rpx;
  display: flex;
  align-items: center;
}

.form-label {
  font-size: 24rpx;
  color: #666;
  margin-right: 10rpx;
  width: 100rpx;
  text-align: left;
}

.form-input {
  flex: 1;
  border: 1rpx solid #ccc;
  border-radius: 5rpx;
  padding: 10rpx;
  font-size: 24rpx;
}

.form-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 20rpx;
}

.form-button {
  background-color: #007aff;
  color: white;
  border: none;
  padding: 10rpx 20rpx;
  border-radius: 10rpx;
  font-size: 24rpx;
  width: 48%;
  text-align: center;
}

.save-button {
  background-color: #007aff;
}

.cancel-button {
  background-color: #ff5555;
}
</style>